package org.airlink.persistence.criteria.expressions
{
	import flash.utils.Dictionary;
	
	import flex.persistence.criteria.Expression;
	
	import org.airlink.persistence.criteria.CriteriaBuilderImpl;
	import org.airlink.persistence.criteria.PredicateImpl;
	
	public class Between extends PredicateImpl {
		
		public function Between (criteriaBuilder:CriteriaBuilderImpl, v:Expression, x:*, y:*) {		
			_parameters =  new Array();
			if(x is Expression)
				_parameters["x"] = x;
			else
				_parameters["x"] = criteriaBuilder.pushParameter(x);
			if(y is Expression)
				_parameters["y"] = y;
			else
				_parameters["y"] = criteriaBuilder.pushParameter(y);		
			_parameters["v"] = v;
		}		
		
		override public function toString():String{
			var result:String = "";
			result += "(" + _parameters["v"] + " between ";		
			if(_parameters["x"] is Expression)
				result += _parameters["x"];
			else 
				result += ":p"+_parameters["x"];					
			result += " and ";
			if(_parameters["y"] is Expression)
				result += _parameters["y"];
			else 
				result += ":p"+_parameters["y"];			
			result += ")";
			return result;		
		}
	}
}